package network2;

public class test {
    public void wiggleSort(int[] nums) {
        int maxIndex = 0;
        for(int i = 1; i < nums.length-1; i+=2){
            if(nums[i] > nums[i-1]){
                maxIndex = i;
            }else {
                maxIndex = i-1;
            }

            if(nums[i+1] > nums[maxIndex]){
                maxIndex = i+1;
            }

            swap(nums,maxIndex,i);
        }

    }
    private static void swap(int[] arr, int i, int j){
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    public static void main(String[] args) {

    }
}
